package com.oms.module.merchant.controller;

import com.oms.common.ResponseDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.Random;

/**
 * @Author zhanghailong QQ38592077
 * @Description TODO
 * @Date 2020/8/17 17:25
 */
@RestController
@Api("商家公告")
@RequestMapping("/user")
public class AnnouncementController {

    @Autowired
    SimpMessagingTemplate simpMessagingTemplate;

    @GetMapping("/announcement")
    @ApiOperation("获取公告列表")
    public ResponseDTO getAnnouncement(Principal principal){
        int nextInt = new Random().nextInt(100);
        simpMessagingTemplate.convertAndSendToUser(principal.getName(),"/queue/message",nextInt);
        return ResponseDTO.succ();
    }
}
